#include <iostream>
#include <String.h>
#include <windows.h>
;
using namespace std;
class QuizEngine
    {
private:
        string Quizname, Question, AnswerA, AnswerB, AnswerC, input, Correct, Grammar;
        int Points, Initalized;
        void RunGrammarQuizCorrect()
        {
            Points++;
            system("cls");
            cout << "Correct answer! \n";
            system("pause > nul");
            system("cls");
        }
        void RunGrammarQuizFail()
        {
            Points--;
            system("cls");
            cout << "Incorrect answer!\nTIP: Use grammar when answering this";
            system("pause > nul");
            system("cls");
        }
        void RunQuizCorrect()
        {
            Points++;
            system("cls");
            cout << "Correct answer! \n";
            system("pause > nul");
            system("cls");
        }
        void RunQuizFail()
        {
            Points--;
            system("cls");
            cout << "Incorrect answer! \n";
            system("pause > nul");
            system("cls");
        }
    public:
        void Init(string QuizName)
        {
            Initalized=1;
            Points=0;
            system("cls");
            system("title Quiz Engine");
            cout << "Quiz Engine v1.0\n\n";
            cout << "Quiz: " + QuizName;
            cout << "\nPress a random key to start the quiz...";
            system("pause > nul");
            system("cls");
        }
        void SetQuizName(string NAME)
        {
            Quizname = NAME;
        }
        void SetQuestion(string QUESTION)
        {
            Question = QUESTION;
        }
        void SetAnswers(string A, string B, string C, string CORRECT)
        {
            if(Initalized==1)
            {
                AnswerA = A;
                AnswerB = B;
                AnswerC = C;
                if (CORRECT=="1")
                {
                    Correct=AnswerA;
                }
                if (CORRECT=="2")
                {
                    Correct=AnswerB;
                }
                if (CORRECT=="3")
                {
                    Correct=AnswerC;
                }
                if (CORRECT!="1"||CORRECT!="2"||CORRECT!="3")
                {
                    cout << "ERROR: Value CORRECT is invalid.";
                }
            }else Correct="";

        }
        void SetGrammarAnswer(string word)
        {
            if(Initalized==1)
            {
                Grammar=word;
            }else Grammar="";
        }
        int RunQuiz()
        {
            if(Initalized==1)
            {
                system("cls");
                cout << Question << "\n" << "A: " << AnswerA << "\nB: " << AnswerB << "\nC: " << AnswerC << "\nYour Answer: ";
                getline(cin, input);
                if (input==Correct)
                {
                    RunQuizCorrect();
                    goto End1;
                }
                else if (input!=Correct)
                {
                RunQuizFail();
                goto End1;
                }
                else cout << "The program shall not get here";
            }else return 0;
            End1:
            return 0;
        }
        int RunGrammarQuiz()
        {
            if(Initalized==1)
            {
                system("cls");
                cout << Question << "\nYour Answer: ";
                getline(cin, input);
                if (input==Grammar)
                {
                    RunGrammarQuizCorrect();
                    goto End2;
                }
                else if (input!=Grammar)
                {
                    RunGrammarQuizFail();
                    goto End2;
                }
                else cout << "The program shall not get here";
            }else return 0;
            End2:
            return 0;
        }
        int EndQuiz()
        {
            if(Initalized==1)
            {
                system("cls");
                cout << "Your Score is "<< Points << "!";
                system("pause > nul");
            } else {cout << "Engine not initalized.\n"; system("pause > nul");}
            return 0;
        }
    }
